<template>
	<view class="content">
		<view>
			<cu-custom @handLeft='handLeft' bgColor="bg-black" :isBack="false">
				<block slot="content">法律与秩序</block>
			</cu-custom>
			<home ref='home' :bottom='bottom' :showBtn='showBtn' v-if="PageCur=='home'"></home>
			<searchLawyer v-if="PageCur=='searchLawyer'" ref='searchLawyer'></searchLawyer>
			<news v-if="PageCur=='news'" ref='news'></news>
			<message v-if="PageCur=='message'"></message>
		</view>
		<view class="my-mb">
			
		</view>
		<view class="cu-bar tabbar my_fex bg-white" style="z-index: 9999999999;">
			<view class="action" @click="handNav" data-cur="home" :class="PageCur=='home'?'text-blue2':'text-gray'">
				<view class="cuIcon-home"></view> 首页
			</view>
			<view class="action" @click="handNav" data-cur="searchLawyer" :class="PageCur=='searchLawyer'?'text-blue2':'text-gray'">
				<view class="cuIcon-search"></view> 找律师
			</view>
			<view @click="handAsk" class="action text-gray add-action">
				<button class="cu-btn cuIcon-question bg-green shadow" style="background-color: #F7B500;"></button>
				问一下
			</view>
			<view class="action" @click="handNav" data-cur="news" :class="PageCur=='news'?'text-blue2':'text-gray'">
				<view class="cuIcon-discover">
					<view class="cu-tag badge"></view>
				</view>
				发现
			</view>
			<view class="action" @click="handNav" data-cur="message" :class="PageCur=='message'?'text-blue2':'text-gray'">
				<view class="cuIcon-friendfavor">
				</view>
				我的
			</view>
		</view>
		<view class="cu-modal drawer-modal justify-start" :class="modalName=='DrawerModalL'?'show':''" @tap="hideModal">
			<view class="cu-dialog basis-lg" @tap.stop="" :style="[{top:CustomBar+'px',height:'calc(100vh - ' + CustomBar + 'px)'}]">
				<view class="cu-list menu text-left">
					<myUser :showTop='false'></myUser>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import myUser from '../message/message'
	export default {
		components: {
			myUser,
		},
		data() {
			return {
				PageCur: 'home',
				showBtn: false,
				bottom: 0,
				modalName: null,
				CustomBar: this.CustomBar,
			}
		},
		async onPullDownRefresh() {
			if (this.$refs.home) {
				if (this.$refs.home.TabCur == 0) {
					await this.$refs.home.getMore()
				}
				if (this.$refs.home.TabCur == 1) {
					await this.$refs.home.getMore2()
				}
			}
			if (this.$refs.news) {
				await this.$refs.news.getMore()
			}
			if (this.PageCur == 'searchLawyer') {
				this.$refs.searchLawyer.lawyerName = ''
				this.$refs.searchLawyer.lawyerAddress = ''
				await this.$refs.searchLawyer.getMore()
				
			}
			uni.stopPullDownRefresh()
			this.$forceUpdate()
		},
		async onReachBottom() {
			console.log(this.TabCur, '???')
			if (this.$refs.home) {
				if (this.$refs.home.TabCur == 0) {
					this.$refs.home.loadMore()
				}
				if (this.$refs.home.TabCur == 1) {
					this.$refs.home.loadMore2()
				}

			}
			if (this.PageCur == 'searchLawyer') {
				await this.$refs.searchLawyer.loadMore()
			}

		},
		async onShow() {
			// uni.pageScrollTo({
			// 	scrollTop: 0,
			// 	duration: 300
			// });
			// await this.$refs.home.getMore()
		},
		onPageScroll(e) {

			if (e.scrollTop > 470) {
				this.showBtn = true
				this.bottom = 120
			} else {
				this.showBtn = false
				this.bottom = 0
			}
		},
		methods: {
			handAsk() {
				uni.navigateTo({
					url: '/pages/home/consultForm/consultForm',
					fail: function(err) {
						console.info("跳转失败", err)
					}
				})
			},
			hideModal() {
				this.modalName = null
			},
			handLeft(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			handNav(e) {
				this.PageCur = e.currentTarget.dataset.cur
			},
		}
	}
</script>

<style lang="scss">
	// .hover_big{
	// 	transform: scale(1.1);
	// 	transition: all 1s ; 
	// }
	.my_fex {
		position: fixed;
		bottom: 0;
		width: 100%;
	}

	/* 	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	} */

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
